package edu.ahut.corejava;

public class JoinNumbers3 {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        int n = 100009;
        int s = 0;
        for (int i = 1; i <= n; i++) {
            s += len3(i);
        }
        System.out.println(s);


        long end = System.currentTimeMillis();


        System.out.println((end - start) / 1000.0 + " second(s).");
    }

    private static int len(int x) {
        int ans = 0;
        while (x > 0) {
            ans++;
            x /= 10;
        }
        return ans;
    }

    private static int len2(int x) {

        return x < 10 ? 1 : len2(x / 10) + 1;
    }

    private static int len3(int x) {
        return (int) (Math.log10(x) + 1);
    }
}
